import "./index.scss";
import { Button } from "antd";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { login } from "@/request/api";
export default function Login() {
  let navigateTo = useNavigate();
  let [username, setUsername] = useState("");
  let [psd, setPsd] = useState("");
  let goTologin = async () => {
    console.log(username, psd);
    let res = await login({ username, psd });
    if (res.code == 0) {
      sessionStorage.setItem("token", JSON.stringify(res.uuid));
      navigateTo("/home");
    }
  };
  return (
    <div className="login">
      <h3>我是login页面</h3>
      <input type="text" onInput={(e: any) => setUsername(e.target.value)} />
      <br />
      <input type="text" onInput={(e: any) => setPsd(e.target.value)} />
      <br />
      <Button onClick={goTologin}>登录</Button>
    </div>
  );
}
